import { wxRequest } from '../../utils/server.js';
const _wxRequest = new wxRequest();
const app = getApp()

Page({
  data: {
    imgUrl: app.globalData.imgUrl,
    list:[],
    pageNo:1
  },

   onShow:function(){
     this.getList()
   },


  //推荐活动/资讯
  getList: function () {
    _wxRequest.wxAjax({
      url: app.globalData.apiUrl + '/sys/info/list',
      method: 'POST'
    }, (res) => {
      let list = res.list;
      if (this.data.pageNo !== 1) {
        list = this.data.list.concat(list);
      }
      list.map(item=>{
        item.modifyDateText = item.modifyDate.substring(0,10)
      })
      this.setData({
        list: list,
        pageNo: res.page.pageNo,
        hasNextPage: res.page.hasNextPage,
      }); 
    })
  },
  

  //下拉刷新
  onPullDownRefresh: function () {
    this.refreshData();
    wx.stopPullDownRefresh()
  },

  refreshData: function () {
    this.setData({
      pageNo: 1
    })
    this.getList();
  },

  toArticle:function(e){
    var id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/pages/activity/detail?id='+id,
    })
  }



})